<template>
  <div class="marketingGoodsList" :style="{minHeight:$store.state.minHeight+'rem'}">
    <header>
      <div class="top">
        <img src="../../../static/img/zuojiantou.png" alt="" @click="back">
        <span>{{title}}</span>
        <router-link :to="page" tag="span" class="add">添加</router-link>
      </div>
      <div class="goodsList" v-if="typeId!=3">
        <div v-for="(x,y) in goodsList" class="goods_box" :key="y" @click="isTab(y)">
          <p :class="y != present?'selected':''">{{x.text}}</p>
          <transition name="el-zoom-in-center">
            <p v-show="y == present"></p>
          </transition>
        </div>
      </div>
    </header>
    <div class="quan_wrap" v-if="typeId==3">
      <div class="quan_box">
        <div class="box_bg">
          <img src="../../../static/img/business/quan_bg.png" alt="">
        </div>
        <div class="jiao">已发放</div>
        <div class="quan_content">
          <div class="quan_left">
            <div class="price">
              <span>￥</span>
              <span>20</span>
            </div>
            <div class="condition">满300元可用</div>
          </div>
          <div class="quan_center">
            <div class="quan_title">邀请好友红包</div>
            <div class="quan_time">有效期至2019-12-31</div>
          </div>
          <div class="quan_right">已 发 放</div>
        </div>
      </div>
    </div>
    <div class="wrap" v-else>
      <div class="box">
        <div class="box_top">
          <div class="left">
            <div class="img">
              <img src="../../../static/img/tianquan.png" alt="">
            </div>
          </div>
          <div class="right">
            <div class="name">BABYHOST 五一周新款 砂锅黄焖 鸡+茄子</div>
            <div class="price">¥1999.00</div>
            <div class="time">上架时间：2016-07-15 14:00</div>
            <div class="sale">
              <div class="number">已售：2153</div>
              <div class="stock">库存：14755</div>
            </div>
          </div>
          <div class="status">
            <div>进行中</div>
            <van-icon name="arrow" color="#999999" size="16" />
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
  import Vue from 'vue';
  import { Icon } from 'vant';

  Vue.use(Icon);

  export default {
      name: "marketingGoodsList",
      data() {
        return {
          title:"商品管理",
          typeId:false,
          page:"/views/Business/addMarketingGoods?id="+this.typeId,
          goodsList: [
            {text: '进行中'},
            {text: '已结束'}
            ],
          present: 0,
        }
      },
    created() {
      console.log(this.$route.query.id);
      if(this.$route.query.id){
        this.typeId = this.$route.query.id;
        this.page = "/views/Business/addMarketingGoods?id=" + this.$route.query.id
      }
      if(this.$route.query.id == 0){
        this.title = "抢购商品"
      }else if(this.$route.query.id == 1){
        this.title = "拼团商品"
      }else if(this.$route.query.id == 2){
        this.title = "砍价商品"
      }else if(this.$route.query.id == 3){
        this.title = "优惠券"
      }else if(this.$route.query.id == 4){
        this.title = "满减活动"
      }else if(this.$route.query.id == 5){
        this.title = "打折促销"
      }
    },
    methods: {
      back() {
        this.$router.back();
      },
      isTab(index){
        this.present = index;
      },
    },
    mounted() {

    },
    watch:{
        // page(){
        //   console.log(this.page)
        // }
    }
  }
</script>

<style scoped>
  .marketingGoodsList{
    background: #F5F5F5;
  }

  .marketingGoodsList header {
    width: 100%;
    position: fixed;
    top: 0;
    left: 0;
    z-index: 88;
    flex-flow: row;
    box-sizing: border-box;
  }
  .marketingGoodsList header .top{
    height: .5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: linear-gradient(170deg,rgba(251,68,72,1) 0%,rgba(254,111,77,1) 100%);
    padding: 0 .1rem;
  }
  .marketingGoodsList header > div > img {
    width: .11rem;
    height: .18rem;
  }

  .marketingGoodsList header > div > span {
    font-size: .18rem;
    font-weight: 500;
    color: #ffffff;
  }
  .marketingGoodsList header .add{
    font-size: .16rem;
    font-weight: normal;
  }

  /* 拼团分类部分 */
  .marketingGoodsList .goodsList {
    padding: 0 .44rem;
    height: 100%;
    max-height: .45rem;
    display: flex;
    flex-flow: row;
    justify-content: space-between;
    /*align-items: center;*/
    background-color: #ffffff;
  }

  .marketingGoodsList .goods_box {
    height: 100%;
    max-height: .55rem;
    width: calc(100% / 2);
    display: flex;
    flex-flow: column;
    justify-content: space-between;
    /*align-items: center;*/
    box-sizing: border-box;
    text-align: center;
  }

  .marketingGoodsList .goods_box > p:nth-child(1) {
    color: #FB4448;
    font-size: .16rem;
    line-height: .16rem;
    padding: .15rem 0 .13rem;
  }

  .marketingGoodsList .goods_box > p:nth-child(2) {
    width: 100%;
    height: .02rem;
    background-color: #FF300D;
    border-radius: .01rem;
  }


  .el-loading-spinner {
    width: 100%;
    position: absolute;
    top: 0;
    left: 0;
    min-height: 5rem;
  }

  .selected {
    color: #333333 !important;
    font-size: .16rem !important;
  }
  /* 商品列表部分 */
  .marketingGoodsList .wrap{
    padding-top: .96rem;
  }
  .marketingGoodsList .box {
    width: 3.54rem;
    box-sizing: border-box;
    background: rgba(255, 255, 255, 1);
    box-shadow: 0 .03rem .15rem 0 rgba(4, 0, 0, 0.15);
    border-radius: .07rem .07rem .07rem .07rem;
    margin: .1rem auto;
    padding:.1rem 0;
  }
  .marketingGoodsList .box_top{
    display: flex;
    justify-content: space-between;
    margin: 0 .1rem;
  }
  .marketingGoodsList .left{
    width: 1rem;
    margin-right: .1rem;
  }
  .marketingGoodsList .name{
    font-size: .15rem;
    line-height: .18rem;
    font-weight: bold;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    width: 1.6rem;
    height: .18rem;
    color: #333333;
  }
  .marketingGoodsList .sale{
    display: flex;
    font-size: .13rem;
    color: #999999;
  }
  .marketingGoodsList .number{
    margin-right: .3rem;
  }
  .marketingGoodsList .time{
    font-size: .13rem;
    color: #999999;
    margin: .04rem 0 .08rem;
  }
  .marketingGoodsList .price{
    color: #FB4448;
    font-size: .18rem;
    margin: .08rem 0;
  }
  .marketingGoodsList .status>div{
    margin-bottom: .3rem;
    color: #FB4448;
    font-size: .14rem;
    width: 100%;
    text-align: right;
  }
  .marketingGoodsList .status i{
    float: right;
  }

  /**优惠券样式**/
  .marketingGoodsList .quan_wrap{
    padding-top: .6rem;
  }
  .marketingGoodsList .quan_box{
    position: relative;
    margin: 0 auto;
    width: 3.45rem;
    height: 1rem;
    overflow: hidden;
  }
  .marketingGoodsList .quan_box .box_bg{
    width: 100%;
    height: 100%;
    position: absolute;
  }
  .marketingGoodsList .quan_box .jiao{
    position: absolute;
    top: .05rem;
    left: -.14rem;
    z-index: 9;
    background: #FFEA8B;
    padding: .02rem .1rem;
    transform: rotate(-45deg);
    color: #EC7636;
  }
  .marketingGoodsList .quan_box .quan_content{
    position: relative;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: .14rem;
  }

  .marketingGoodsList .quan_box .quan_content .quan_left{
    width: 1rem;
    text-align: center;
    color: #ffffff;
  }
  .marketingGoodsList .quan_box .quan_content .quan_left .price{
    color: #ffffff;
    margin: 0;
  }
  .marketingGoodsList .quan_box .quan_content .quan_left .price span:nth-child(1){
    font-size: .25rem;
  }
  .marketingGoodsList .quan_box .quan_content .quan_left .price span:nth-child(2){
    font-size: .4rem;
  }
  .marketingGoodsList .quan_box .quan_content .quan_center .quan_title{
    font-size: .16rem;
    color: #333333;
  }
  .marketingGoodsList .quan_box .quan_content .quan_center .quan_time{
    margin-top: .15rem;
    font-size: .12rem;
    color: #999999;
  }
  .marketingGoodsList .quan_box .quan_content .quan_right{
    writing-mode:vertical-lr;
    color: #FB4448;
    font-size: .12rem;
    margin-right: .15rem;
  }
</style>
